<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<title>Welcome to mymeme</title>
		<script src="/mymeme/js/service.js" type="text/javascript"></script>
		<script src="/mymeme/ext/mootools-1.2.4-core-nc.js" type="text/javascript"></script>
		<link href="/mymeme/css/meme.css" rel="stylesheet"/>
	</head>
	<body>
		<div class="banner">
			<h1>第三方meme客户端</h1>
			<div class="navigator">
					<a href="popular.html">popular</a>
					<a href="#home"  onclick="toDashBoard()">home</a>
					<a href="index.html">myMeme</a>
			</div>
		</div>
		<div class="posts" id="homePosts">
			
		</div>
		<div class="nextpage">
			
			<button name="More" onclick="morePage();" value="More" title="More" type="button">More</button> 
		</div>
	</body>
</html>

<script type="text/javascript">
	window.addEvent("load",function(){
		var u = User();
		var query ={
			q:"SELECT * FROM meme.following WHERE owner_guid= '"+u.guid+"'",
			format:'json',
			asyn:false,
			cbFunction:function(reply){
				var m = reply.query.results.meme;
				$each(m,function(meme){
					var tmp ={};
					tmp.guid = meme.guid;
					tmp.name = meme.name;
					following.push(tmp);
				});
			}
		};
		new Ajax(query);
			//
		dashBoardQuery();
	});
	var following = [];
	var dashBoardQuery = function(){
		
		$each(following,function(meme){
			var query = {
				q:"select * from meme.posts("+curpage*pageSize+","+pageSize+")  where owner_guid ='"+meme.guid+"'",
				format:'json',
				cbFunction:'homePosts'
			};
				new Ajax(query);	
		});
 	}
		var homePosts = function(reply){
			var posts = reply.query.results.post ;
			if(posts){
				if (posts.length > 0) {
					//meme.post
					post(posts).inject($("homePosts"));
				}else {
					alert("no any posts found! type another user again.");
				}
			}
		}
	
</script>